package com.wolfalpha.lwtool.service;

import com.wolfalpha.lwtool.service.impl.UserServiceImpl;
import com.wolfalpha.lwtool.vo.CountInfo;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;

public class MyService extends Service {
	UserService sav = new UserServiceImpl();
	private boolean running = true;
	static final String TAG = "MyService";

	@Override
	public IBinder onBind(Intent arg0) {
		Log.d(TAG, "onBind");
		return null;
	}

	@Override
	public void onCreate() {
		Log.d(TAG, "onCreate");
		super.onCreate();

		new Thread(new Runnable() {

			@Override
			public void run() {
				while (running) {
					try {
						CountInfo cf = sav.adminGetCount();
						if(cf == null){
							Log.i(TAG, "null");
							//sav.adminLogin("postmaster", "123root");
							continue;
						}
						if (cf.getUnAudited_company() > 0) {
							Log.i(TAG, "com>0");
						}
						if (cf.getUnAudited_job() > 0) {
							Log.i(TAG, "job>0");
						}
					} catch (Exception e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
						
					}
					Log.i(TAG, "running");
				}
			}
		}).start();

	}

	@Override
	public void onDestroy() {
		Log.d(TAG, "onDestroy");
		super.onDestroy();
	}

}
